import { APlugin } from '../types/common.interface';
import { TableDatas } from '../cors/table-datas';
import { Injectable, PluginInjectable } from '../decorators/inject';
import { Select } from '../cors/select';
import { ExecuteRecord } from '../cors/execute-record';
import './col-width.plugin.less';
import { RenderTrigger } from '../cors/render-trigger';
import { FillCommand } from '../commands/fill-command';
import { FullControl } from '../cors/full-control';
@Injectable()
@PluginInjectable('FillPlugin')
export class FillPlugin extends APlugin {
    constructor(
        protected datas: TableDatas,
        protected executeRecord: ExecuteRecord,
        protected renderTrigger: RenderTrigger,
        protected select: Select,
        protected fullCtl: FullControl
    ) {
        super();
    }
    public init() {

    }
    public fill(color: string) {
        if(color == null) {
            let command = new FillCommand(this.datas, this.select.selected, this.renderTrigger, this.fullCtl, null);
            this.executeRecord.execute(command);
        } else {
            let command = new FillCommand(this.datas, this.select.selected, this.renderTrigger, this.fullCtl, {background: {color: color}});
            this.executeRecord.execute(command);
        }
    }
    public destroy() {

    }
}